package com.atguigu.util;

import com.atguigu.bean.WaterSensor;

import java.text.SimpleDateFormat;
import java.util.ArrayList;
import java.util.List;

/**
 * Author: Pepsi
 * Date: 2023/8/2
 * Desc:
 */
public class AnqclnUtil {

    // 要先声明泛型
    public static <T>List<T> toList(Iterable<T> elements) {
        List<T> list = new ArrayList<>();

        for (T t : elements) {
            list.add(t);
        }
        return list;
    }

    public static String toDateTime(long ts) {
        return new SimpleDateFormat("yyyy-MM-dd HH:mm:ss").format(ts);
    }

    public static String toDate(Long ts) {
        return new SimpleDateFormat("yyyy-MM-dd").format(ts);
    }
}
